import java.io.OutputStream;
import java.net.Socket;

import com.tunnel.common.util.StringUtil;

public class TcpClient {

    public static void main(String[] args) throws Exception {
    	Socket socket = null;
    	try {
			socket = new Socket("127.0.0.1",4444);
			System.out.println("client 请求连接");
			OutputStream write = socket.getOutputStream();
			for(int i=0;i<10;i++){
				Thread.sleep(1000);
				String str = StringUtil.getRandomString(10);
				System.out.println("写数据："+str);
				write.write(str.getBytes());
			}
			socket.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				socket.close();
			} catch (Exception e2) {}
		}
    	
    }

}